package com.hulu73.struts1.utils;

public class RequestUtils {
	
	public static Object applicationInstance(String className)
	        throws ClassNotFoundException, IllegalAccessException,
	            InstantiationException {
	        return applicationInstance(className, null);
	    }

	 public static Object applicationInstance(String className,
		        ClassLoader classLoader)
		        throws ClassNotFoundException, IllegalAccessException,
		            InstantiationException {
		        return (applicationClass(className, classLoader).newInstance());
		    }
	 
	    public static Class applicationClass(String className,
	            ClassLoader classLoader)
	            throws ClassNotFoundException {
	            if (classLoader == null) {
	                // Look up the class loader to be used
	                classLoader = Thread.currentThread().getContextClassLoader();

	                if (classLoader == null) {
	                    classLoader = RequestUtils.class.getClassLoader();
	                }
	            }

	            // Attempt to load the specified class
	            return (classLoader.loadClass(className));
	        }
	
}
